/**
 * 
 */
package com.douyu.ocean.recom.platfrom.core.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.douyu.ocean.recom.platform.api.model.entiry.RecomBiz;
import com.douyu.ocean.recom.platform.api.model.entiry.RecomPos;
import com.douyu.ocean.recom.platfrom.core.dal.mapper.RecomBizMapper;
import com.douyu.ocean.recom.platfrom.core.service.RecomBizService;

import tk.mybatis.mapper.entity.Example;

/**
 * @author leiruiqi
 *
 */
@Service("recomBizService")
public class RecomBizServiceImpl implements RecomBizService{

	@Resource
	private RecomBizMapper  recomBizMapper;
	
	@Override
	public void save(RecomBiz recomBiz) {
		
		recomBizMapper.insertSelective(recomBiz);
		
	}

	@Override
	public List<RecomBiz> queryAllByStatus(Integer status) {
		
		Example condition = new Example(RecomBiz.class);
		condition.orderBy("id").asc();
		condition.createCriteria().andEqualTo("status", 0);
		return recomBizMapper.selectByExample(condition);
	}

	@Override
	public boolean updateById(RecomBiz algorithm) {
		return 1==recomBizMapper.updateByPrimaryKeySelective(algorithm);
	}

	@Override
	public RecomBiz getByCode(String code) {
		RecomBiz record = new RecomBiz();
		record.setCode(code);
		return recomBizMapper.selectOne(record);
	}

	@Override
	public RecomBiz getById(Long id) {
		RecomBiz record = new RecomBiz();
		record.setId(id);
		return recomBizMapper.selectOne(record);
	}

}
